﻿CREATE PROCEDURE [dbo].[pr_OtExplanation]
AS
BEGIN
	IF object_id('tempdb..#GroupExplanationAll') IS NOT NULL 
	BEGIN
		 DROP TABLE #GroupExplanationAll
	END

	IF object_id('tempdb..#ExplanationAll') IS NOT NULL 
	BEGIN
		 DROP TABLE #ExplanationAll
	END

select
	p.ScenarioId,
	r.Name,
	sum(p.NatSignJanUSDAmount) as Jan,
	sum(p.NatSignFebUSDAmount) as Feb,
	sum(p.NatSignMarUSDAmount) as Mar,
	sum(p.NatSignAprUSDAmount) as Apr,
	sum(p.NatSignMayUSDAmount) as May,
	sum(p.NatSignJunUSDAmount) as Jun,
	sum(p.NatSignJulUSDAmount) as Jul,
	sum(p.NatSignAugUSDAmount) as Aug,
	sum(p.NatSignSepUSDAmount) as Sep,
	sum(p.NatSignOctUSDAmount) as Oct,
	sum(p.NatSignNovUSDAmount) as Nov,
	sum(p.NatSignDecUSDAmount) as Dec
	into #GroupExplanationAll
	from Pearl p 
	inner join goc g  on
	p.Goc = g.GocAttribute
	inner join [dbo].[Rule] r on
	g.RuleId = r.Id
	where p.AccountLeaf in (2829,2830) and
	p.ScenarioId in (1, 2, 5) and
	p.Date = (select MAX(ld.Date) from Pearl ld)
	group by p.ScenarioId,
	r.Name
	order by r.Name

--drop table #GroupExplanationAll

	select distinct Name, 
	ISNULL((select Jan from #GroupExplanationAll e where (e.ScenarioId = 1 or e.ScenarioId = 5) and e.Name = g.Name), 0) AS JanPlan,
	ISNULL((select Jan from #GroupExplanationAll e where e.ScenarioId = 2 and e.Name = g.Name), 0) AS JanActual,
	ISNULL((select Feb from #GroupExplanationAll e where (e.ScenarioId = 1 or e.ScenarioId = 5) and e.Name = g.Name), 0) AS FebPlan,
	ISNULL((select Feb from #GroupExplanationAll e where e.ScenarioId = 2 and e.Name = g.Name), 0) AS FebActual,
	ISNULL((select Mar from #GroupExplanationAll e where (e.ScenarioId = 1 or e.ScenarioId = 5) and e.Name = g.Name), 0) AS MarPlan,
	ISNULL((select Mar from #GroupExplanationAll e where e.ScenarioId = 2 and e.Name = g.Name), 0) AS MarActual,
	ISNULL((select Apr from #GroupExplanationAll e where (e.ScenarioId = 1 or e.ScenarioId = 5) and e.Name = g.Name), 0) AS AprPlan,
	ISNULL((select Apr from #GroupExplanationAll e where e.ScenarioId = 2 and e.Name = g.Name), 0) AS AprActual,
	ISNULL((select May from #GroupExplanationAll e where (e.ScenarioId = 1 or e.ScenarioId = 5) and e.Name = g.Name), 0) AS MayPlan,
	ISNULL((select May from #GroupExplanationAll e where e.ScenarioId = 2 and e.Name = g.Name), 0) AS MayActual,
	ISNULL((select Jun from #GroupExplanationAll e where (e.ScenarioId = 1 or e.ScenarioId = 5) and e.Name = g.Name), 0) AS JunPlan,
	ISNULL((select Jun from #GroupExplanationAll e where e.ScenarioId = 2 and e.Name = g.Name), 0) AS JunActual,
	ISNULL((select Jul from #GroupExplanationAll e where (e.ScenarioId = 1 or e.ScenarioId = 5) and e.Name = g.Name), 0) AS JulPlan,
	ISNULL((select Jul from #GroupExplanationAll e where e.ScenarioId = 2 and e.Name = g.Name), 0) AS JulActual,
	ISNULL((select Aug from #GroupExplanationAll e where (e.ScenarioId = 1 or e.ScenarioId = 5) and e.Name = g.Name), 0) AS AugPlan,
	ISNULL((select Aug from #GroupExplanationAll e where e.ScenarioId = 2 and e.Name = g.Name), 0) AS AugActual,
	ISNULL((select Sep from #GroupExplanationAll e where (e.ScenarioId = 1 or e.ScenarioId = 5) and e.Name = g.Name), 0) AS SepPlan,
	ISNULL((select Sep from #GroupExplanationAll e where e.ScenarioId = 2 and e.Name = g.Name), 0) AS SepActual,
	ISNULL((select Oct from #GroupExplanationAll e where (e.ScenarioId = 1 or e.ScenarioId = 5) and e.Name = g.Name), 0) AS OctPlan,
	ISNULL((select Oct from #GroupExplanationAll e where e.ScenarioId = 2 and e.Name = g.Name), 0) AS OctActual,
	ISNULL((select Nov from #GroupExplanationAll e where (e.ScenarioId = 1 or e.ScenarioId = 5) and e.Name = g.Name), 0) AS NovPlan,
	ISNULL((select Nov from #GroupExplanationAll e where e.ScenarioId = 2 and e.Name = g.Name), 0) AS NovActual,
	ISNULL((select Dec from #GroupExplanationAll e where (e.ScenarioId = 1 or e.ScenarioId = 5) and e.Name = g.Name), 0) AS DecPlan,
	ISNULL((select Dec from #GroupExplanationAll e where e.ScenarioId = 2 and e.Name = g.Name), 0) AS DecActual
	into #ExplanationAll
	from #GroupExplanationAll g
		
	select 
	e.Name,
	CAST(e.JanPlan AS INT) AS JanPlan,
	CAST(e.JanActual AS INT) AS JanActual,
	CAST((e.JanPlan - e.JanActual) AS INT) As JanVar,
	CAST(e.FebPlan AS INT) AS FebPlan,
	CAST(e.FebActual AS INT) AS FebActual,
	CAST((e.FebPlan - e.FebActual) AS INT) As FebVar,
	CAST(e.MarPlan AS INT) AS MarPlan,
	CAST(e.MarActual AS INT) AS MarActual,
	CAST((e.MarPlan - e.MarActual) AS INT) As MarVar,
	CAST(e.AprPlan AS INT) AS AprPlan,
	CAST(e.AprActual AS INT) AS AprActual,
	CAST((e.AprPlan - e.AprActual) AS INT) As AprVar,
	CAST(e.MayPlan AS INT) AS MayPlan,
	CAST(e.MayActual AS INT) AS MayActual,
	CAST((e.MayPlan - e.MayActual) AS INT) As MayVar,
	CAST(e.JunPlan AS INT) AS JunPlan,
	CAST(e.JunActual AS INT) AS JunActual,
	CAST((e.JunPlan - e.JunActual) AS INT) As JunVar,
	CAST(e.JulPlan AS INT) AS JulPlan,
	CAST(e.JulActual AS INT) AS JulActual,
	CAST((e.JulPlan - e.JulActual) AS INT) As JulVar,
	CAST(e.AugPlan AS INT) AS AugPlan,
	CAST(e.AugActual AS INT) AS AugActual,
	CAST((e.AugPlan - e.AugActual) AS INT) As AugVar,
	CAST(e.SepPlan AS INT) AS SepPlan,
	CAST(e.SepActual AS INT) AS SepActual,
	CAST((e.SepPlan - e.SepActual) AS INT) As SepVar,
	CAST(e.OctPlan AS INT) AS OctPlan,
	CAST(e.OctActual AS INT) AS OctActual,
	CAST((e.OctPlan - e.OctActual) AS INT) As OctVar,
	CAST(e.NovPlan AS INT) AS NovPlan,
	CAST(e.NovActual AS INT) AS NovActual,
	CAST((e.NovPlan - e.NovActual) AS INT) As NovVar,
	CAST(e.DecPlan AS INT) AS DecPlan,
	CAST(e.DecActual AS INT) AS DecActual,
	CAST((e.DecPlan - e.DecActual) AS INT) As DecVar,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/01' and r.Name = e.Name and jp.JustifyStatusId in (2, 3, 4, 5)) as JanVolumes,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/01' and r.Name = e.Name and jp.JustifyStatusId = 1) as JanOpenPositions,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/01' and r.Name = e.Name and jp.JustifyStatusId = 6) as JanProjects,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/02' and r.Name = e.Name and jp.JustifyStatusId in (2, 3, 4, 5)) as FebVolumes,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/02' and r.Name = e.Name and jp.JustifyStatusId = 1) as FebOpenPositions,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/02' and r.Name = e.Name and jp.JustifyStatusId = 6) as FebProjects,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/03' and r.Name = e.Name and jp.JustifyStatusId in (2, 3, 4, 5)) as MarVolumes,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/03' and r.Name = e.Name and jp.JustifyStatusId = 1) as MarOpenPositions,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/03' and r.Name = e.Name and jp.JustifyStatusId = 6) as MarProjects,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/04' and r.Name = e.Name and jp.JustifyStatusId in (2, 3, 4, 5)) as AprVolumes,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/04' and r.Name = e.Name and jp.JustifyStatusId = 1) as AprOpenPositions,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/04' and r.Name = e.Name and jp.JustifyStatusId = 6) as AprProjects,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/05' and r.Name = e.Name and jp.JustifyStatusId in (2, 3, 4, 5)) as MayVolumes,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/05' and r.Name = e.Name and jp.JustifyStatusId = 1) as MayOpenPositions,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/05' and r.Name = e.Name and jp.JustifyStatusId = 6) as MayProjects,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/06' and r.Name = e.Name and jp.JustifyStatusId in (2, 3, 4, 5)) as JunVolumes,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/06' and r.Name = e.Name and jp.JustifyStatusId = 1) as JunOpenPositions,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/06' and r.Name = e.Name and jp.JustifyStatusId = 6) as JunProjects,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/07' and r.Name = e.Name and jp.JustifyStatusId in (2, 3, 4, 5)) as JulVolumes,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/07' and r.Name = e.Name and jp.JustifyStatusId = 1) as JulOpenPositions,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/07' and r.Name = e.Name and jp.JustifyStatusId = 6) as JulProjects,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/08' and r.Name = e.Name and jp.JustifyStatusId in (2, 3, 4, 5)) as AugVolumes,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/08' and r.Name = e.Name and jp.JustifyStatusId = 1) as AugOpenPositions,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/08' and r.Name = e.Name and jp.JustifyStatusId = 6) as AugProjects,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/09' and r.Name = e.Name and jp.JustifyStatusId in (2, 3, 4, 5)) as SepVolumes,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/09' and r.Name = e.Name and jp.JustifyStatusId = 1) as SepOpenPositions,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/09' and r.Name = e.Name and jp.JustifyStatusId = 6) as SepProjects,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/10' and r.Name = e.Name and jp.JustifyStatusId in (2, 3, 4, 5)) as OctVolumes,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/10' and r.Name = e.Name and jp.JustifyStatusId = 1) as OctOpenPositions,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/10' and r.Name = e.Name and jp.JustifyStatusId = 6) as OctProjects,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/11' and r.Name = e.Name and jp.JustifyStatusId in (2, 3, 4, 5)) as NovVolumes,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/11' and r.Name = e.Name and jp.JustifyStatusId = 1) as NovOpenPositions,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/11' and r.Name = e.Name and jp.JustifyStatusId = 6) as NovProjects,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/12' and r.Name = e.Name and jp.JustifyStatusId in (2, 3, 4, 5)) as DecVolumes,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/12' and r.Name = e.Name and jp.JustifyStatusId = 1) as DecOpenPositions,
	(select COUNT(1) from JustifyPosition jp inner join Position p on jp.PositionId = p.Id
	inner join Goc g on g.GocAttribute = p.GocAttribute
	inner join [dbo].[Rule] r on g.RuleId = r.Id
	where CONVERT(VARCHAR(7), jp.Date, 111) = CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '/12' and r.Name = e.Name and jp.JustifyStatusId = 6) as DecProjects
	
	from #ExplanationAll e
END